package com.ny.demo.demo523;

import java.sql.SQLException;
import java.util.Scanner;

public class Maintest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException, SQLException {
        UserNew userNew = new UserNew();
        System.out.println("用户系统");
        while (true){
            System.out.println("1.注册");
            System.out.println("2.登录");
            System.out.println("3.退出");
            Scanner scanner = new Scanner(System.in);
            System.out.println("请选择项目");
            int choice = scanner.nextInt();
            switch (choice){
                case 1:
                    System.out.println("请输入用户名");
                    String username = scanner.next();
                    System.out.println("请输入密码");
                    String password = scanner.next();
                    int regiUser = userNew.regUser(username, password);
                    if (regiUser > 0){
                        System.out.println("注册成功");
                    }else {
                        System.out.println("注册失败");
                    }
                    break;
                    case 2:
                        System.out.println("请输入用户名");
                        String uname = scanner.next();
                        System.out.println("请输入密码");
                        String pass = scanner.next();
                        Users users = UserNew.loginuser(uname,pass);
                        if (users != null){
                            System.out.println("登录成功");
                        }else {
                            System.out.println("登录失败");
                        }

            }

        }
    }
}
